package com.cos.edoc.services.impl;

import com.cos.edoc.dao.EdocEntryMapper;
import com.cos.edoc.entity.EdocEntry;
import com.cos.edoc.services.EdocEntryServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: COS
 * @time: 2022/3/14 14:36
 * @description:
 */
@Service
public class EdocEntryServicesImpl implements EdocEntryServices {
    @Autowired
    private EdocEntryMapper entryMapper;

    @Override
    public List<EdocEntry> getBooksBycategoryId(Integer categoryId) {
        return entryMapper.getBooksBycategoryId(categoryId);
    }

    @Override
    public List<EdocEntry> getAllBook() {
        return entryMapper.getAllBook();
    }

    @Override
    public boolean del(Integer id) {
        if (id != null && id != 0) {
            if (entryMapper.del(id) > 0) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean add(EdocEntry entry) {
        if (entry != null) {
            if (entryMapper.add(entry) > 0) {
                return true;
            }
        }
        return false;
    }
    @Override
    public boolean update(EdocEntry entry) {
        if (entry != null) {
            if (entryMapper.update(entry) > 0) {
                return true;
            }
        }
        return false;
    }

    @Override
    public EdocEntry getBookById(Integer id) {
        if (id!=null&&id!=0) {
            return entryMapper.getBookById(id);
        }
        return null;
    }

}
